package day18;

import java.util.concurrent.locks.ReentrantLock;

//lock锁模拟死锁
public class Demo5 {
    ReentrantLock lock=new ReentrantLock();

    public void deadLock(){
        String  name=Thread.currentThread().getName();
        System.out.println(name+"尝试获取lock锁...");
        lock.lock(); //加锁
        System.out.println(name+"获取到了lock锁...");
        //没有释放
    }
    public static void main(String[] args) {
        Demo5 d=new Demo5();
        new Thread(()->{
            d.deadLock();
        },"广志").start();
        new Thread(()->{
            d.deadLock();
        },"志广").start();
        new Thread(()->{
            d.deadLock();
        },"章鱼大帅哥").start();
    }
}
